﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace BussinessLayer
{
    public class tblhoatdong
    {
        DataLayer.Data odata = new DataLayer.Data();
        public void hoatdong(int _id, string _ten, DateTime _thoigian, int _cap,string _noidung, bool _batbuoc, int _hocki, string _namhoc, bool _trangthai)
        {
            SqlParameter[] sp = new SqlParameter[9];
            sp[0] = new SqlParameter("@hoatdong_id", _id);
            sp[1] = new SqlParameter("@hoatdong_ten", _ten);
            sp[2] = new SqlParameter("@hoatdong_thoigian", _thoigian);
            sp[3] = new SqlParameter("@hoatdong_cap", _cap);
            sp[4] = new SqlParameter("@hoatdong_noidung", _noidung);
            sp[5] = new SqlParameter("@hoatdong_batbuoc", _batbuoc);
            sp[6] = new SqlParameter("@hoatdong_hocki", _hocki);
            sp[7] = new SqlParameter("@hoatdong_namhoc", _namhoc);
            sp[8] = new SqlParameter("@hoatdong_trangthai", _trangthai);
            odata.proc_TS("tblHoatdong", sp);
        }
        public void delete(int id, bool trangthai)
        {
            odata.view_text("update hoatdong set hoatdong_trangthai='" + trangthai + "' where hoatdong_id='" + id + "'");
        }
        public DataTable SelectAllhoatdong()
        {
            return odata.view_text("SELECT * FROM hoatdong");
        }
        public DataTable SelectAllhoatdongNamhoc(string y)
        {
            return odata.view_text("SELECT * FROM hoatdong where hoatdong_namhoc='"+y+"'");
        }
        public DataTable SelectHDTrongNamHoc(string namhoc)
        {
            return odata.view_text("select * from hoatdong where hoatdong_namhoc='" + namhoc + "' and hoatdong_trangthai='True'");
        }
    }
}
